/**
 * <p>Copyright:Copyright(c) 2019</p>
 * <p>Company:Professional</p>
 * <p>Package:ces.org.course.watch</p>
 * <p>File:FileListenerRunner.java</p>
 * <p>类更新历史信息</p>
 * @todo chanlong(陈龙) 创建于 May 17, 2019 4:47:28 PM
 */
package ces.org.course.cuixiaowei.api.watch;

import ces.org.course.cuixiaowei.cfg.FileProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * <p>描述: </p>
 * <p>Company: Professional</p>
 * @author chanlong(陈龙)
 * @date May 17, 2019 4:47:28 PM
 * @version 1.0.2019
 */
@Component
public class FileListenerRunner implements CommandLineRunner {
	@Autowired
	private FileProperties fileProperties;
	private static final String UPLOAD_TRIGGER   = "auto";

	@Override
	public void run(String... args) throws Exception {
		/**
		 *  是否启动自动更新模式
		 */
		if(fileProperties.getUpdate().equals(UPLOAD_TRIGGER)){
			try {
				factory.monitor().start();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	@Autowired
    private FileListenerFactory factory;
}
